home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / term-Source.lha / TransferPanel.c < prev    next >
C/C++ Source or Header  |  1995-06-17  |  16KB  |  676 lines

  1. /*
  2. **    TransferPanel.c
  3. **
  4. **    File transfer control panel support routines
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. STATIC BYTE LastStatus        = -1;
  13. STATIC LONG TransferInfoCount    = 0;
  14.  
  15. STATIC ULONG __saveds __asm
  16. ListViewRender(register __a0 struct Hook *Hook,register __a1 struct LVDrawMsg *Msg,register __a2 struct Node *Node)
  17. {
  18.         /* We only know how to redraw lines. */
  19.  
  20.     if(Msg -> lvdm_MethodID == LV_DRAW)
  21.     {
  22.         struct RastPort    *RPort    = Msg -> lvdm_RastPort;
  23.         LONG         Left    = Msg -> lvdm_Bounds . MinX,
  24.                  Top    = Msg -> lvdm_Bounds . MinY,
  25.                  Width    = Msg -> lvdm_Bounds . MaxX - Msg -> lvdm_Bounds . MinX + 1,
  26.                  Height    = Msg -> lvdm_Bounds . MaxY - Msg -> lvdm_Bounds . MinY + 1,
  27.                  FgPen,BgPen,
  28.                  Len,LabelLen;
  29.         STRPTR         String = Node -> ln_Name;
  30.  
  31.             /* Determine the rendering pens. */
  32.  
  33.         switch(Msg -> lvdm_State)
  34.         {
  35.             case LVR_SELECTEDDISABLED:
  36.             case LVR_NORMALDISABLED:
  37.             case LVR_NORMAL:
  38.  
  39.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[TEXTPEN];
  40.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[BACKGROUNDPEN];
  41.                 break;
  42.  
  43.             case LVR_SELECTED:
  44.  
  45.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLTEXTPEN];
  46.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLPEN];
  47.                 break;
  48.         }
  49.  
  50.         SetABPenDrMd(RPort,BgPen,BgPen,JAM2);
  51.         RectFill(RPort,Left,Top,Left + 1,Top + Height - 1);
  52.  
  53.         Left    += 2;
  54.         Width    -= 2;
  55.  
  56.             /* Is this an error message? */
  57.  
  58.         if(*String++ == '*' && BgPen != Msg -> lvdm_DrawInfo -> dri_Pens[HIGHLIGHTTEXTPEN])
  59.             FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[HIGHLIGHTTEXTPEN];
  60.  
  61.             /* Determine length of vanilla name. */
  62.  
  63.         LabelLen = strlen(String);
  64.  
  65.             /* Try to make it fit. */
  66.  
  67.         while(LabelLen > 0 && (Len = TextLength(RPort,String,LabelLen)) > Width)
  68.             LabelLen--;
  69.  
  70.             /* Print the vanilla name if possible. */
  71.  
  72.         if(LabelLen)
  73.         {
  74.             SetAPen(RPort,FgPen);
  75.  
  76.             Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
  77.             Text(RPort,String,LabelLen);
  78.  
  79.             Left    += Len;
  80.             Width    -= Len;
  81.         }
  82.  
  83.             /* Fill the area to follow the vanilla name. */
  84.  
  85.         if(Width > 0)
  86.         {
  87.             SetAPen(RPort,BgPen);
  88.  
  89.             RectFill(RPort,Left,Top,Left + Width - 1,Top + Height - 1);
  90.         }
  91.  
  92.             /* If the item happens to be disabled, draw the cross-hatch
  93.              * pattern across it.
  94.              */
  95.  
  96.         if(Msg -> lvdm_State == LVR_SELECTEDDISABLED || Msg -> lvdm_State == LVR_NORMALDISABLED)
  97.         {
  98.             SetABPenDrMd(RPort,Msg -> lvdm_DrawInfo -> dri_Pens[BLOCKPEN],0,JAM1);
  99.  
  100.             SetAfPt(RPort,(UWORD *)&Ghosting,1);
  101.  
  102.             RectFill(RPort,Msg -> lvdm_Bounds . MinX,Msg -> lvdm_Bounds . MinY,Msg -> lvdm_Bounds . MaxX,Msg -> lvdm_Bounds . MaxY);
  103.  
  104.             SetAfPt(RPort,NULL,0);
  105.         }
  106.  
  107.         return(LVCB_OK);
  108.     }
  109.     else
  110.         return(LVCB_UNKNOWN);
  111. }
  112.  
  113.     /* AddTransferInfo(STRPTR Message,...):
  114.      *
  115.      *    Add another entry to the transfer information list.
  116.      */
  117.  
  118. VOID __stdargs
  119. AddTransferInfo(BOOLEAN Error,STRPTR Message,...)
  120. {
  121.     STATIC UBYTE __far TempBuffer[256];
  122.  
  123.     struct Node    *Node;
  124.     va_list         VarArgs;
  125.  
  126.     if(Kick30)
  127.     {
  128.         va_start(VarArgs,Message);
  129.         VSPrintf(&TempBuffer[1],Message,VarArgs);
  130.         va_end(VarArgs);
  131.  
  132.         if(Error)
  133.             TempBuffer[0] = '*';
  134.         else
  135.             TempBuffer[0] = ' ';
  136.     }
  137.     else
  138.     {
  139.         va_start(VarArgs,Message);
  140.         VSPrintf(TempBuffer,Message,VarArgs);
  141.         va_end(VarArgs);
  142.     }
  143.  
  144.     if(Node = CreateNode(TempBuffer))
  145.     {
  146.         LT_SetAttributes(TransferHandle,GAD_TRANSFER_INFORMATION_LIST,
  147.             GTLV_Labels,    ~0,
  148.         TAG_DONE);
  149.  
  150.         if(TransferInfoCount == 100)
  151.         {
  152.             FreeVecPooled(RemHead(&TransferInfoList));
  153.  
  154.             TransferInfoCount = 99;
  155.         }
  156.  
  157.         AddTail(&TransferInfoList,Node);
  158.  
  159.         LT_SetAttributes(TransferHandle,GAD_TRANSFER_INFORMATION_LIST,
  160.             GTLV_Labels,        &TransferInfoList,
  161.             GTLV_Top,        TransferInfoCount,
  162.             GTLV_MakeVisible,    TransferInfoCount,
  163.         TAG_DONE);
  164.  
  165.         TransferInfoCount++;
  166.     }
  167. }
  168.  
  169.     /* TransferPanel(STRPTR Title):
  170.      *
  171.      *    Open the transfer window.
  172.      */
  173.  
  174. BYTE __regargs
  175. TransferPanel(STRPTR Title)
  176. {
  177.     if(TransferWindow)
  178.         return(TRUE);
  179.     else
  180.     {
  181.         STATIC struct Hook ListViewHook =
  182.         {
  183.             {NULL},
  184.             (HOOKFUNC)ListViewRender
  185.         };
  186.  
  187.         TransferFailed = TransferAborted = FALSE;
  188.  
  189.         if(Status != STATUS_DOWNLOAD && Status != STATUS_UPLOAD)
  190.         {
  191.             LastStatus = Status;
  192.  
  193.             Status = STATUS_DOWNLOAD;
  194.         }
  195.         else
  196.             LastStatus = -1;
  197.  
  198.         if(Window)
  199.             TransferHandle = LT_CreateHandleTags(Window -> WScreen,LH_LocaleHook,&LocaleHook,TAG_DONE);
  200.         else
  201.             TransferHandle = LT_CreateHandleTags(NULL,LH_LocaleHook,&LocaleHook,TAG_DONE);
  202.  
  203.         if(TransferHandle)
  204.         {
  205.             struct IBox Bounds;
  206.  
  207.             LT_New(TransferHandle,
  208.                 LA_Type,    VERTICAL_KIND,
  209.             TAG_DONE);
  210.             {
  211.                 LT_New(TransferHandle,
  212.                     LA_Type,    VERTICAL_KIND,
  213. /*                    LA_LabelID,    MSG_V36_1509,*/
  214.                 TAG_DONE);
  215.                 {
  216.                     LT_New(TransferHandle,
  217.                         LA_Type,        VERTICAL_KIND,
  218.                     TAG_DONE);
  219.                     {
  220.                         UBYTE    LocalBuffer[60];
  221.                         WORD    Len;
  222.  
  223.                         strcpy(LocalBuffer,FilePart(LastXprLibrary));
  224.  
  225.                         if((Len = strlen(LocalBuffer)) > 3)
  226.                         {
  227.                             UBYTE    ProtocolBuffer[60];
  228.                             WORD    i;
  229.  
  230.                             strcpy(ProtocolBuffer,&LocalBuffer[3]);
  231.  
  232.                             for(i = 0 ; i < Len - 3 ; i++)
  233.                             {
  234.                                 if(ProtocolBuffer[i] == '.')
  235.                                 {
  236.                                     ProtocolBuffer[i] = 0;
  237.  
  238.                                     break;
  239.                                 }
  240.                             }
  241.  
  242.                             ProtocolBuffer[0] = ToUpper(ProtocolBuffer[0]);
  243.  
  244.                             SPrintf(LocalBuffer,"[%s]",ProtocolBuffer);
  245.                         }
  246.                         else
  247.                             strcpy(LocalBuffer,"-");
  248.  
  249.                         LT_New(TransferHandle,
  250.                             LA_Type,    TEXT_KIND,
  251.                             LA_LabelID,    MSG_TRANSFERPANEL_PROTOCOL_TXT,
  252.                             LA_Chars,    50,
  253.                             LA_ID,        GAD_TRANSFER_PROTOCOL,
  254.                             GTTX_Text,    LocalBuffer,
  255.                             GTTX_CopyText,    TRUE,
  256.                             GTTX_Border,    TRUE,
  257.                         TAG_DONE);
  258.  
  259.                         LT_New(TransferHandle,
  260.                             LA_Type,    LISTVIEW_KIND,
  261.                             LA_LabelID,    MSG_TRANSFERPANEL_INFORMATION_GAD,
  262.                             LA_LabelPlace,    PLACE_LEFT,
  263.                             LA_ID,        GAD_TRANSFER_INFORMATION_LIST,
  264.                             LA_Chars,    50,
  265.                             LA_Lines,    2,
  266.                             LALV_MaxGrowX,    70,
  267.                             LALV_MaxGrowY,    10,
  268.                             LALV_CursorKey,    TRUE,
  269.                             GTLV_ReadOnly,    TRUE,
  270.                             GTLV_CallBack,    &ListViewHook,
  271.                             GTLV_MaxPen,    MAX(TransferHandle -> DrawInfo -> dri_Pens[BLOCKPEN],MAX(TransferHandle -> DrawInfo -> dri_Pens[TEXTPEN],MAX(TransferHandle -> DrawInfo -> dri_Pens[BACKGROUNDPEN],MAX(TransferHandle -> DrawInfo -> dri_Pens[FILLTEXTPEN],MAX(TransferHandle -> DrawInfo -> dri_Pens[FILLPEN],TransferHandle -> DrawInfo -> dri_Pens[HIGHLIGHTTEXTPEN]))))),
  272.                         TAG_DONE);
  273.  
  274.                         LT_New(TransferHandle,
  275.                             LA_Type,    XBAR_KIND,
  276.                         TAG_DONE);
  277.  
  278.                         LT_EndGroup(TransferHandle);
  279.                     }
  280.  
  281.                     LT_New(TransferHandle,
  282.                         LA_Type,    VERTICAL_KIND,
  283.                     TAG_DONE);
  284.                     {
  285.                         LT_New(TransferHandle,
  286.                             LA_Type,        BOX_KIND,
  287.                             LA_ID,            GAD_TRANSFER_FILE,
  288.                             LA_Chars,        50,
  289.                             LABX_FirstLabel,    MSG_TRANSFERPANEL_FILE_TXT,
  290.                             LABX_LastLabel,        MSG_TRANSFERPANEL_COMPLETION_TIME_TXT,
  291.                             LABX_ReserveSpace,    TRUE,
  292.                         TAG_DONE);
  293.  
  294.                         LT_New(TransferHandle,
  295.                             LA_Type,    XBAR_KIND,
  296.                         TAG_DONE);
  297.  
  298.                         LT_EndGroup(TransferHandle);
  299.                     }
  300.  
  301.                     LT_New(TransferHandle,
  302.                         LA_Type,    HORIZONTAL_KIND,
  303.                     TAG_DONE);
  304.                     {
  305.                         LT_New(TransferHandle,
  306.                             LA_Type,    VERTICAL_KIND,
  307.                         TAG_DONE);
  308.                         {
  309.                             LT_New(TransferHandle,
  310.                                 LA_Type,        BOX_KIND,
  311.                                 LA_ID,            GAD_TRANSFER_SIZE,
  312.                                 LA_Chars,        15,
  313.                                 LABX_FirstLabel,    MSG_TRANSFERPANEL_FILE_SIZE_TXT,
  314.                                 LABX_LastLabel,        MSG_TRANSFERPANEL_BLOCKS_TRANSFERRED_TXT,
  315.                                 LABX_ReserveSpace,    TRUE,
  316.                             TAG_DONE);
  317.  
  318.                             LT_New(TransferHandle,
  319.                                 LA_Type,        BOX_KIND,
  320.                                 LA_ID,            GAD_TRANSFER_TOTALTIME,
  321.                                 LABX_FirstLabel,    MSG_TRANSFERPANEL_ESTIMATED_TIME_TXT,
  322.                                 LABX_LastLabel,        MSG_TRANSFERPANEL_ELAPSED_TIME_TXT,
  323.                                 LABX_ReserveSpace,    TRUE,
  324.                             TAG_DONE);
  325.  
  326.                             LT_New(TransferHandle,
  327.                                 LA_Type,    GAUGE_KIND,
  328.                                 LA_ID,        GAD_TRANSFER_PERCENT,
  329.                                 LA_LabelID,    MSG_TRANSFERPANEL_DATA_TRANSFERRED_GAD,
  330.                                 LAGA_InfoLength,4,
  331.                             TAG_DONE);
  332.  
  333.                             LT_EndGroup(TransferHandle);
  334.                         }
  335.  
  336.                         LT_New(TransferHandle,
  337.                             LA_Type,        VERTICAL_KIND,
  338.                             LAGR_LastAttributes,    TRUE,
  339.                         TAG_DONE);
  340.                         {
  341.                             LT_New(TransferHandle,
  342.                                 LA_Type,        BOX_KIND,
  343.                                 LA_ID,            GAD_TRANSFER_SECONDS,
  344.                                 LA_Chars,        15,
  345.                                 LABX_FirstLabel,    MSG_TRANSFERPANEL_CHARACTERS_PER_SECOND_TXT,
  346.                                 LABX_LastLabel,        MSG_TRANSFERPANEL_BLOCK_SIZE_TXT,
  347.                                 LABX_ReserveSpace,    TRUE,
  348.                             TAG_DONE);
  349.  
  350.                             LT_New(TransferHandle,
  351.                                 LA_Type,        BOX_KIND,
  352.                                 LA_ID,            GAD_TRANSFER_ERRORS,
  353.                                 LABX_FirstLabel,    MSG_TRANSFERPANEL_NUMBER_OF_ERRORS_TXT,
  354.                                 LABX_LastLabel,        MSG_TRANSFERPANEL_NUMBER_OF_TIMEOUTS_TXT,
  355.                                 LABX_ReserveSpace,    TRUE,
  356.                             TAG_DONE);
  357.  
  358.                             LT_New(TransferHandle,
  359.                                 LA_Type,    GAUGE_KIND,
  360.                                 LA_ID,        GAD_TRANSFER_TIME,
  361.                                 LA_LabelID,    MSG_TRANSFERPANEL_TIME_TO_GO_GAD,
  362.                                 LAGA_InfoLength,8,
  363.                             TAG_DONE);
  364.  
  365.                             LT_EndGroup(TransferHandle);
  366.                         }
  367.  
  368.                         LT_EndGroup(TransferHandle);
  369.                     }
  370.  
  371.                     LT_EndGroup(TransferHandle);
  372.                 }
  373.  
  374.                 LT_New(TransferHandle,
  375.                     LA_Type,VERTICAL_KIND,
  376.                 TAG_DONE);
  377.                 {
  378.                     LT_New(TransferHandle,
  379.                         LA_Type,    XBAR_KIND,
  380.                         LAXB_FullSize,    TRUE,
  381.                     TAG_DONE);
  382.  
  383.                     LT_EndGroup(TransferHandle);
  384.                 }
  385.  
  386.                 LT_New(TransferHandle,LA_Type,HORIZONTAL_KIND,
  387.                     LAGR_Spread,    TRUE,
  388.                 TAG_DONE);
  389.                 {
  390.                     LT_New(TransferHandle,
  391.                         LA_Type,    BUTTON_KIND,
  392.                         LA_LabelID,    MSG_TRANSFERPANEL_SKIP_CURRENT_FILE_GAD,
  393.                         LA_ID,        GAD_TRANSFER_SKIP,
  394.                         LABT_ExtraFat,    TRUE,
  395.                     TAG_DONE);
  396.  
  397.                     LT_New(TransferHandle,
  398.                         LA_Type,    BUTTON_KIND,
  399.                         LA_LabelID,    MSG_TRANSFERPANEL_ABORT_CURRENT_FILE_GAD,
  400.                         LA_ID,        GAD_TRANSFER_ABORT_FILE,
  401.                         LABT_ExtraFat,    TRUE,
  402.                     TAG_DONE);
  403.  
  404.                     LT_New(TransferHandle,
  405.                         LA_Type,    BUTTON_KIND,
  406.                         LA_LabelID,    MSG_TRANSFERPANEL_ABORT_ENTIRE_TRANSFER_GAD,
  407.                         LA_ID,        GAD_TRANSFER_ABORT,
  408.                         LABT_EscKey,    TRUE,
  409.                         LABT_ExtraFat,    TRUE,
  410.                     TAG_DONE);
  411.  
  412.                     LT_EndGroup(TransferHandle);
  413.                 }
  414.  
  415.                 LT_EndGroup(TransferHandle);
  416.             }
  417.  
  418.             TransferZoomed = FALSE;
  419.  
  420.             if(Window)
  421.             {
  422.                 Bounds . Left    = WindowLeft + Window -> LeftEdge;
  423.                 Bounds . Top    = WindowTop + Window -> TopEdge;
  424.             }
  425.             else
  426.             {
  427.                 Bounds . Left    = WindowLeft;
  428.                 Bounds . Top    = WindowTop;
  429.             }
  430.  
  431.             Bounds . Width    = WindowWidth;
  432.             Bounds . Height    = WindowHeight;
  433.  
  434.             if(TransferWindow = LT_Layout(TransferHandle,TransferWindowTitle = Title,&Bounds,0,0,IDCMP_CLOSEWINDOW,0,
  435.                 LAWN_HelpHook,        &GuideHook,
  436. //                LAWN_Parent,        Window,
  437.                 WA_DepthGadget,        TRUE,
  438.                 WA_CloseGadget,        TRUE,
  439.                 WA_DragBar,        TRUE,
  440.                 WA_RMBTrap,        TRUE,
  441.                 LAWN_Zoom,        TRUE,
  442.             TAG_DONE))
  443.             {
  444.                 ULONG    IntuiLock = LockIBase(NULL);
  445.                 BYTE    Activate,Move;
  446.                 LONG    i;
  447.  
  448.                 GuideContext(CONTEXT_TRANSFER);
  449.  
  450.                 if(Config -> MiscConfig -> AlertMode == ALERT_SCREEN || Config -> MiscConfig -> AlertMode == ALERT_BEEP_SCREEN)
  451.                     Move = Activate = TRUE;
  452.                 else
  453.                 {
  454.                     if(IntuitionBase -> ActiveScreen == TransferWindow -> WScreen)
  455.                         Activate = TRUE;
  456.                     else
  457.                         Activate = FALSE;
  458.  
  459.                     Move = FALSE;
  460.                 }
  461.  
  462.                 if(Config -> TransferConfig -> TransferNotification == XFERNOTIFY_NEVER || Config -> TransferConfig -> TransferNotification == XFERNOTIFY_END)
  463.                     Move = Activate = FALSE;
  464.  
  465.                 UnlockIBase(IntuiLock);
  466.  
  467.                 if(Move)
  468.                 {
  469.                     if(TransferWindow -> WScreen -> LeftEdge > 0)
  470.                     {
  471.                         if(TransferWindow -> WScreen -> TopEdge > 0)
  472.                             MoveScreen(TransferWindow -> WScreen,-TransferWindow -> WScreen -> LeftEdge,-TransferWindow -> WScreen -> TopEdge);
  473.                         else
  474.                             MoveScreen(TransferWindow -> WScreen,-TransferWindow -> WScreen -> LeftEdge,0);
  475.                     }
  476.                     else
  477.                     {
  478.                         if(TransferWindow -> WScreen -> TopEdge > 0)
  479.                             MoveScreen(TransferWindow -> WScreen,0,-TransferWindow -> WScreen -> TopEdge);
  480.                     }
  481.  
  482.                     WindowToFront(TransferWindow);
  483.  
  484.                     ScreenToFront(TransferWindow -> WScreen);
  485.                 }
  486.  
  487.                 if(Activate)
  488.                     ActivateWindow(TransferWindow);
  489.  
  490.                 PushWindow(TransferWindow);
  491.  
  492.                 for(i = 0 ; i < 6 ; i++)
  493.                 {
  494.                     if(i < 4)
  495.                     {
  496.                         if(i < 2)
  497.                         {
  498.                             LT_SetAttributes(TransferHandle,GAD_TRANSFER_TOTALTIME,
  499.                                 LABX_Index,    i,
  500.                                 LABX_Text,    "-",
  501.                             TAG_DONE);
  502.  
  503.                             LT_SetAttributes(TransferHandle,GAD_TRANSFER_ERRORS,
  504.                                 LABX_Index,    i,
  505.                                 LABX_Text,    "-",
  506.                             TAG_DONE);
  507.                         }
  508.  
  509.                         LT_SetAttributes(TransferHandle,GAD_TRANSFER_FILE,
  510.                             LABX_Index,    i,
  511.                             LABX_Text,    "-",
  512.                         TAG_DONE);
  513.                     }
  514.  
  515.                     LT_SetAttributes(TransferHandle,GAD_TRANSFER_SIZE,
  516.                         LABX_Index,    i,
  517.                         LABX_Text,    "-",
  518.                     TAG_DONE);
  519.  
  520.                     LT_SetAttributes(TransferHandle,GAD_TRANSFER_SECONDS,
  521.                         LABX_Index,    i,
  522.                         LABX_Text,    "-",
  523.                     TAG_DONE);
  524.                 }
  525.  
  526.                 if(Config -> TransferConfig -> PerfMeter && Window)
  527.                 {
  528.                     LONG    Left    = 0,
  529.                         Top    = 0,
  530.                         Width    = 0,
  531.                         Height    = 0;
  532.  
  533.                     GetWindowInfo(WINDOW_PERF,&Left,&Top,&Width,&Height,Window -> Width / 2,Window -> Height / 4);
  534.  
  535.                     if(TransferPerfWindow = OpenWindowTags(NULL,
  536.                         WA_Left,        Left,
  537.                         WA_Top,            Top,
  538.                         WA_Width,        Width,
  539.                         WA_Height,        Height,
  540.                         WA_DragBar,        TRUE,
  541.                         WA_DepthGadget,        TRUE,
  542.                         WA_SizeGadget,        TRUE,
  543.                         WA_SizeBBottom,        TRUE,
  544.                         WA_RMBTrap,        TRUE,
  545.                         WA_NoCareRefresh,    TRUE,
  546.                         WA_CloseGadget,        TRUE,
  547.                         WA_CustomScreen,    Window -> WScreen,
  548.                         WA_Title,        LocaleString(MSG_TERMXPR_TRANSFER_PERFMETER_TXT),
  549.                         WA_MinWidth,        Window -> WScreen -> WBorLeft + 30 + Window -> WScreen -> WBorRight,
  550.                         WA_MinHeight,        Window -> WScreen -> WBorTop + Window -> WScreen -> Font -> ta_YSize + 1 + 20 + Window -> WScreen -> WBorBottom,
  551.                         WA_MaxWidth,        Window -> WScreen -> Width,
  552.                         WA_MaxHeight,        Window -> WScreen -> Height,
  553.                     TAG_DONE))
  554.                     {
  555.                         extern LONG CPL_Min,CPL_Avg,CPL_Cur;
  556.  
  557.                         CPL_Min = CPL_Avg = CPL_Cur = -1;
  558.  
  559.                         TransferPerfWindow -> UserPort = TransferWindow -> UserPort;
  560.  
  561.                         ModifyIDCMP(TransferPerfWindow,TransferWindow -> IDCMPFlags);
  562.                     }
  563.                 }
  564.  
  565.                 return(TRUE);
  566.             }
  567.  
  568.             LT_DeleteHandle(TransferHandle);
  569.  
  570.             TransferHandle = NULL;
  571.         }
  572.     }
  573.  
  574.     return(FALSE);
  575. }
  576.  
  577.     /* DeleteTransferPanel(BYTE WaitForPrompt):
  578.      *
  579.      *    Close the transfer window.
  580.      */
  581.  
  582. VOID __regargs
  583. DeleteTransferPanel(BYTE WaitForPrompt)
  584. {
  585.         /* Can any pending garbage. */
  586.  
  587.     if(TransferError)
  588.         FlushSerialRead();
  589.  
  590.     if(TransferPerfWindow)
  591.     {
  592.         PutWindowInfo(WINDOW_PERF,TransferPerfWindow -> LeftEdge,TransferPerfWindow -> TopEdge,TransferPerfWindow -> Width,TransferPerfWindow -> Height);
  593.  
  594.         CloseWindowSafely(TransferPerfWindow);
  595.  
  596.         TransferPerfWindow = NULL;
  597.     }
  598.  
  599.         /* Wait for user to close the window? */
  600.  
  601.     if(WaitForPrompt && TransferHandle)
  602.     {
  603.         struct IntuiMessage    *Message;
  604.         BOOLEAN             Done = FALSE;
  605.         ULONG             MsgClass,
  606.                      MsgQualifier;
  607.         UWORD             MsgCode;
  608.         struct Gadget        *MsgGadget;
  609.  
  610.         LT_SetAttributes(TransferHandle,GAD_TRANSFER_SKIP,
  611.             GA_Disabled,    TRUE,
  612.         TAG_DONE);
  613.  
  614.         LT_SetAttributes(TransferHandle,GAD_TRANSFER_ABORT_FILE,
  615.             GA_Disabled,    TRUE,
  616.         TAG_DONE);
  617.  
  618.         do
  619.         {
  620.             if(Wait(PORTMASK(TransferWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  621.                 break;
  622.  
  623.             while(Message = (struct IntuiMessage *)GT_GetIMsg(TransferWindow -> UserPort))
  624.             {
  625.                 MsgClass    = Message -> Class;
  626.                 MsgQualifier    = Message -> Qualifier;
  627.                 MsgCode        = Message -> Code;
  628.                 MsgGadget    = (struct Gadget *)Message -> IAddress;
  629.  
  630.                 GT_ReplyIMsg(Message);
  631.  
  632.                 LT_HandleInput(TransferHandle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
  633.  
  634.                 if(MsgClass == IDCMP_CLOSEWINDOW || (MsgClass == IDCMP_GADGETUP && MsgGadget -> GadgetID == GAD_TRANSFER_ABORT))
  635.                     Done = TRUE;
  636.             }
  637.         }
  638.         while(!Done);
  639.     }
  640.  
  641.     TransferAbortState = 0;
  642.     TransferAbortCount = 0;
  643.  
  644.     TransferError = FALSE;
  645.  
  646.     if(FileTransferInfo)
  647.     {
  648.         FreeFileTransferInfo(FileTransferInfo);
  649.  
  650.         FileTransferInfo = NULL;
  651.     }
  652.  
  653.     if(LastStatus != -1)
  654.         Status = LastStatus;
  655.  
  656.     LastStatus = -1;
  657.  
  658.     if(TransferHandle)
  659.     {
  660.         LT_DeleteHandle(TransferHandle);
  661.  
  662.         TransferHandle = NULL;
  663.     }
  664.  
  665.     if(TransferInfoList . lh_Head -> ln_Succ)
  666.     {
  667.         FreeList(&TransferInfoList);
  668.  
  669.         TransferInfoCount = 0;
  670.     }
  671.  
  672.     TransferWindow = NULL;
  673.  
  674.     ReleaseWindows();
  675. }
  676.